<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="<%=request.getContextPath()%>/statics/js/vue.js"></script>
    <script src="<%=request.getContextPath()%>/statics/js/axios.min.js"></script>
</head>
<body>
<div id="app">
    <form>
        <p>
            <label>客户</label>
            <input type="text" name="name" v-model="cus.name">
        </p>
        <p>
            <label>联系人</label>
            <input type="text" name="linkman" v-model="cus.linkman">
        </p>
        <p>
            <label>电话</label>
            <input type="text" name="phone" v-model="cus.phone">
        </p>
        <p>
            <label>日期</label>
            <input type="date" name="createdate" v-model="cus.createdate">
        </p>
        <button type="button" @click="add">添加客户</button>
    </form>
</div>
</body>
</html>
<script>
    var vm = new Vue({
        el:"#app",
        data:{
            cus:{
                name:"",
                linkman:"",
                phone:"",
                createdate:"",
            },
        },
        methods: {
            add:function(){
                axios.post(
                    "http://localhost:8080/shiro_ssm_war_exploded/cus/add.html",
                    {
                        name:vm.cus.name,
                        linkman:vm.cus.linkman,
                        phone:vm.cus.phone,
                        createdate:vm.cus.createdate,
                    }, {
                        headers: {'Content-Type':'application/json'}
                    }
                ).then(res=>{
                    console.log(res.data);
                    window.alert(res.data);
                    window.location.href="<%=request.getContextPath()%>/cus/goList.html";
                }).catch(err=>{
                    console.log(err);
                })
            }
        },
    });
</script>